//
//  NSString+URLEncoding.m
//  SmartCommunity
//
//  Created by Justiseek on 13-8-6.
//  Copyright (c) 2013年 SuperMaxJ. All rights reserved.
//

#import "NSString+URLEncoding.h"

@implementation NSString (URLEncoding)

- (NSString *)URLEncodedString
{
    NSString *result = (NSString *)
	CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
											(CFStringRef)self,
											NULL,
											CFSTR("!*'();:@&amp;=+$,/?%#[] "),
											kCFStringEncodingUTF8);
    [result autorelease];
    return result;
}

- (NSString*)URLDecodedStringText
{
    NSString *result = (NSString *)
	CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
															(CFStringRef)self,
															CFSTR(""),
															kCFStringEncodingUTF8);
    [result autorelease];
    return result;
}

- (NSString*)URLDecodedString
{
    NSString *result = (NSString *)
	CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
															(CFStringRef)self,
															CFSTR(""),
															kCFStringEncodingUTF8);
    [result autorelease];
    return result;
}

@end
